
int Ispalindrome(char *str,int len)   //palindrome 
{ 
	if(*str==*(str+len-1)) 
		return Ispalindrome(str+1,len-2); 
	if(len<=1) 
		return 1; 
	else    
		return 0; 
} 

bool IsSwap(char* pBegin , char* pEnd)  
{  
	char *p;  
	for(p = pBegin ; p < pEnd ; p++)  
	{  
		if(*p == *pEnd)  
			return false;  
	}  
	return true;  
}  

void Permutation(char* pStr, char* pBegin)    //full permutation
{  
	assert(pStr && pBegin);  
	if(*pBegin == '\0') 
	{
		if(Ispalindrome(pStr,strlen(pStr)))
		{
			cout<<pStr<<endl;
		}
	}
	else  
	{  
		for(char* pCh = pBegin; *pCh != '\0'; pCh++)  
		{  
			 if(IsSwap(pBegin , pCh)) 
			 {
				 swap(*pBegin,*pCh);  
				 Permutation(pStr, pBegin+1);  
				 swap(*pBegin,*pCh);  
			 }
			
		}  
	}  
}  



int main() {
	int N;
	cin >>N;
	int i=0;
	string word;
	string sentence;
	while(i<N){
		cin>>word;
		sentence+=word;
		i++;
	}
	char *str=const_cast<char *>(sentence.c_str());
	Permutation(str,str);
	return 0;
}